package threadlocaldemo;

import java.sql.Connection;

public class DBConnectionFactoryDemo {

    public static Connection conn1;
    public static Connection conn2;

    public static void main(String[] args) {

        Thread th1 = new Thread(() -> {
            //super.run();
            conn1 = DBConnectionFactory.getConnection();
        });

        Thread th2 = new Thread(() -> {
            //super.run();
            conn2 = DBConnectionFactory.getConnection();
        });

        th1.start();
        th2.start();

        try{
            th1.join();
            th2.join();
        }catch(Exception ex){
            ex.printStackTrace();
        }
        System.out.println(conn1 == null);
        System.out.println(conn2 == null);

        System.out.println(conn1 == conn2);
    }
}
